package com.wyl.niupi.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 吴宇亮 on 2020/5/6 0006 下午 4:00
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public OpenAPI springShopOpenAPI() {
        //TODO，缺了个是否开启
        return new OpenAPI()
                .info(new Info().title("牛皮系统 API")
                        .description("这是一个swagger文档")
                        .version("v0.0.1")
                        .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                        .description("补充文档")
                        .url("https://springshop.wiki.github.org/docs"));
    }

    @Bean
    public GroupedOpenApi yxcApi() {
        return GroupedOpenApi.builder()
                .group("yxc")
                .pathsToMatch("/yxc/**") //按照访问路径进行分组
                .build();
    }

    @Bean
    public GroupedOpenApi swaggerDemoApi() {
        return GroupedOpenApi.builder()
                .group("swaggerDemoApi")
                .pathsToMatch("/demo/**")
                .build();
    }
}
